package top.shen33.yang.model.entity;

import cn.afterturn.easypoi.excel.annotation.Excel;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import org.apache.commons.lang3.StringUtils;

import java.io.Serializable;
import java.util.Arrays;
import java.util.Collections;
import java.util.Date;
import java.util.List;

/**
 * <p>
 * 正文
 * </p>
 *
 * @author oreilly
 * @since 2018-08-30
 */
//@JsonIgnoreProperties({"tagsList"})
public class EdoPost extends Model<EdoPost> {

private static final long serialVersionUID = 1L;


                @TableId(value = "sid", type = IdType.AUTO)
                
    private Integer sid;
    /**
     * 标题
     */

        
    @Excel(name = "标题",width = 20,orderNum = "0")
    private String sname;
    /**
     * 创建时间
     */

        
    @Excel(name = "创建时间",width = 20,orderNum = "0")
    private Date ctime;
    /**
     * 所属类别
     */

        
    @Excel(name = "所属类别",width = 20,orderNum = "0")
    private Integer cateId;

    @TableField(exist = false)
    private EdoCate edoCate;

    /**
     * 内容
     */

        
    @Excel(name = "内容",width = 20,orderNum = "0")
    private String txt;
    /**
     * 姓名
     */

        
    @Excel(name = "姓名",width = 20,orderNum = "0")
    private String userName;
    /**
     * 电话
     */

        
    @Excel(name = "电话",width = 20,orderNum = "0")
    private String userPhone;

    @Excel(name = "回复数",width = 20,orderNum = "0")
    private Integer replyNum;



    /**
     * tags列表
     */


    @Excel(name = "tags列表",width = 20,orderNum = "0")
    private String tags;
    /**
     * tag id 列表
     */


    @Excel(name = "tag id 列表",width = 20,orderNum = "0")
    private Integer tagIds;


    @TableField(exist = false)
    private List<String> tagsList ;


    public void setTagsList(List<String> tagsList) {
        this.tagsList = tagsList;
    }

    public String getTags() {
        return tags;
    }
    public List<String> getTagsList() {

        if(StringUtils.isEmpty(tags)){
            return Collections.emptyList();
        }
        return Arrays.asList(tags.split("[,]"));
    }

    public void setTags(String tags) {
        this.tags = tags;
    }

    public Integer getTagIds() {
        return tagIds;
    }

    public void setTagIds(Integer tagIds) {
        this.tagIds = tagIds;
    }

    public Integer getReplyNum() {

        if(replyNum == null){
            return 0;
        }

        return replyNum;
    }

    public void setReplyNum(Integer replyNum) {
        this.replyNum = replyNum;
    }

    public EdoCate getEdoCate() {
        return edoCate;
    }

    public void setEdoCate(EdoCate edoCate) {
        this.edoCate = edoCate;
    }


    public String getCateName() {

        if(edoCate ==null){
            return "";
        }
        return edoCate.getSname();
    }

    public Integer getSid() {
            return sid;
    }

    public void setSid(Integer sid) {
            this.sid = sid;
    }

    public String getSname() {
            return sname;
    }

    public void setSname(String sname) {
            this.sname = sname;
    }

    public Date getCtime() {
            return ctime;
    }

    public void setCtime(Date ctime) {
            this.ctime = ctime;
    }

    public Integer getCateId() {
            return cateId;
    }

    public void setCateId(Integer cateId) {
            this.cateId = cateId;
    }

    public String getTxt() {
            return txt;
    }

    public void setTxt(String txt) {
            this.txt = txt;
    }

    public String getUserName() {
            return userName;
    }

    public void setUserName(String userName) {
            this.userName = userName;
    }

    public String getUserPhone() {
            return userPhone;
    }

    public void setUserPhone(String userPhone) {
            this.userPhone = userPhone;
    }

    @Override
    protected Serializable pkVal() {
            return this.sid;
    }

    @Override
    public String toString() {
        return "EdoPost{" +
                ", sid=" + sid +
                ", sname=" + sname +
                ", ctime=" + ctime +
                ", cateId=" + cateId +
                ", txt=" + txt +
                ", userName=" + userName +
                ", userPhone=" + userPhone +
        "}";
    }
}
